import request from '@/router/axios';

// 生产工段
export const getList = (current, size, params) => {
  return request({
    url: '/api/mes-product/product/worksection/page',
    method: 'get',
    params: {
      ...params,
      current,
      size
    }
  });
};

export const add = (row) => {
  return request({
    url: '/api/mes-product/product/worksection/submit',
    method: 'post',
    data: row
  });
};

export const update = (row) => {
  return request({
    url: '/api/mes-product/product/worksection/submit',
    method: 'post',
    data: row
  });
};
export const removeSection = (id) => {
  return request({
    url: '/api/mes-product/product/worksection/remove',
    method: 'get',
    params: {
      id
    }
  });
};
// 检查工段是否可以删除
export const checkSection = (sectionId, lineId) => {
  return request({
    url: '/api/mes-product/product/worksection/remove/check',
    method: 'get',
    params: {
      sectionId,
      lineId
    }
  });
};
export const getAllSection = () => {
  return request({
    url: '/api/mes-product/product/worksection/all-section',
    method: 'get'
  });
};
// 生产工段——详情
export const getDetail = (id) => {
  return request({
    url: '/api/mes-product/product/worksection/detail',
    method: 'get',
    params: {
      id
    }
  });
};

// 生产工段——查询工段日历
export const getCalendarDetail = (sectionId) => {
  return request({
    url: '/api/mes-product/calendar/detail',
    method: 'get',
    params: {
      sectionId
    }
  });
};
// 生产工段——查询时间方案详情
export const getCalendarDayTemplateDetail = (id) => {
  return request({
    url: '/api/mes-product/calendar/detail-calendar-day-template',
    method: 'get',
    params: {
      id
    }
  });
};

export const remove = (ids) => {
  return request({
    url: '/api/mes-product/section/remove',
    method: 'post',
    params: {
      ids
    }
  });
};

export const saveChild = (row) => {
  return request({
    url: '/api/mes-product/work-section/create-children',
    method: 'post',
    data: row
  });
};

export const getSelectLine = (params) => {
  return request({
    url: '/api/mes-product/product/line/list',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const deleteBinding = (params) => {
  return request({
    url: '/api/mes-product/section/delete-binding',
    method: 'get',
    params
  });
};

export const bindingLine = (row, params) => {
  return request({
    url: `/api/mes-product/section/binding-line?sectionId=${params.sectionId}&sectionCode=${params.sectionCode}&sectionName=${params.sectionName}`,
    method: 'post',
    data: row
  });
};

export const disabled = (params) => {
  return request({
    url: '/api/mes-product/section/enable-or-forbidden',
    method: 'get',
    params
  });
};

export const getCapacityList = (params) => {
  return request({
    url: '/api/mes-product/section/capacity/list',
    method: 'get',
    params: {
      ...params
    }
  });
};

export const saveCapacity = (row, sectionId) => {
  return request({
    url: `/api/mes-product/section/capacity/part/save?sectionId=${sectionId}`,
    method: 'post',
    data: row
  });
};

export const deleteCapacity = (ids) => {
  return request({
    url: '/api/mes-product/section/capacity/part/remove',
    method: 'get',
    params: {
      ids
    }
  });
};
